﻿namespace YunQue.DataBase.Configuration.System
{
    /// <summary>
    /// 用户权限实体配置
    /// </summary>
    public class UserPermissionEntityConfiguration: BaseEntityConfiguration<UserPermissionEntity>
    {
        /// <summary>
        /// 配置
        /// </summary>
        /// <param name="builder"></param>
        public override void Configure(EntityTypeBuilder<UserPermissionEntity> builder)
        {
            base.Configure(builder);
            builder.ToTable("user_permission");
            builder.Property(u => u.UserId).HasColumnName("user_id").HasColumnType("varchar").HasMaxLength(100).HasComment("用户Id").IsRequired();
            builder.Property(u => u.PermissionCode).HasColumnName("permission_code").HasColumnType("varchar").HasMaxLength(100).HasComment("权限编码").IsRequired();
            builder.HasIndex(u => u.UserId).HasDatabaseName("idx_user_permission_user_id");
            builder.HasIndex(u => u.PermissionCode).HasDatabaseName("idx_user_permission_permission_code");
            builder.HasIndex(u => new { u.UserId, u.PermissionCode }).IsUnique().HasDatabaseName("idx_user_permission_user_id_permission_code");
        }
    }
}
